using System;
using System.Collections.Generic;
using System.Text;

namespace GameFramework
{
    public class Entity
    {
        private Dictionary<int, State> states = null;
        protected Form form = null;
        protected int ID;
               
        public Entity(int ID)
        {
            states = new Dictionary<int, State>();
            this.ID = ID;
        }

        public Form getForm()
        {
            return form;
        }

        public virtual void Terminate()
        {
            Dictionary<int, State>.ValueCollection collection2 = states.Values;
            foreach (State state in collection2)
                state.Terminate();         

            if (form != null) form.Terminate();
            GameManager.GetCurrent().RemoveEntity(this);
        }

        public State GetState(int stateID)
        {
            State state = null;
            states.TryGetValue(stateID, out state);
            return state;
        }

        protected void AddState(State state)
        {
            states.Add(state.GetID(), state);
        }

        public int GetID()
        {
            return ID;
        }
    }
}
